﻿#include "uicustomdialog.h"

#include <shlib/quc_sdk/iconhelper/icon_helper.h>

UiCustomDialog::UiCustomDialog(QWidget *parent)
    : ElaWidget{parent}
{
    IconHelper* iconsMgr = IconHelper::instance();

    loop = new QEventLoop(this);

    m_accept.setText("确定");
    m_accept.setIcon(QIcon(iconsMgr->getPixmap(QColor::fromString("#63E6BE"), IconHelper::FontAwesome6Solid, 0xf058, 16, 20,20)));
    connect(&m_accept, &QPushButton::clicked, this, &UiCustomDialog::accept);

    m_exit.setText("取消");
    m_exit.setIcon(QIcon(iconsMgr->getPixmap(QColor::fromString("#63E6BE"), IconHelper::FontAwesome6Solid, 0xf00d, 18, 20,20)));
    connect(&m_exit, &QPushButton::clicked, this, &UiCustomDialog::reject);

    m_buttonLayout.addStretch(1);
    m_buttonLayout.addWidget(&m_accept);
    m_buttonLayout.addWidget(&m_exit);
    m_buttonLayout.addStretch(0);

    m_mainLayout.addLayout(&m_contentLayout, 20);
    m_mainLayout.addLayout(&m_buttonLayout, 1);


    setWindowModality(Qt::ApplicationModal); // 设置模态性

    this->setLayout(&m_mainLayout);
}

UiCustomDialog::~UiCustomDialog()
{

}

void UiCustomDialog::setConten(QLayout *layout)
{
    m_contentLayout.addLayout(layout);
}

void UiCustomDialog::setConten(QWidget *widget)
{
    m_contentLayout.addWidget(widget);
}
